<!doctype html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="JAVAWEB," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.0" />






<meta name="description" content="###　Response ###1234567891011121314151617181920212223242526Response对象,用于生成http响应信息. 对于开发人员来讲,就是 向response 对象中添加信息即可.	响应首行		HTTP/1.1  200 OK		void setStatus(int sc) 		void setStatus(int sc, String sm)">
<meta name="keywords" content="JAVAWEB">
<meta property="og:type" content="article">
<meta property="og:title" content="RequesrAndResponse">
<meta property="og:url" content="http://yoursite.com/2017/01/15/RequesrAndResponse/index.html">
<meta property="og:site_name" content="JokerLiang">
<meta property="og:description" content="###　Response ###1234567891011121314151617181920212223242526Response对象,用于生成http响应信息. 对于开发人员来讲,就是 向response 对象中添加信息即可.	响应首行		HTTP/1.1  200 OK		void setStatus(int sc) 		void setStatus(int sc, String sm)">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2017-03-14T03:41:10.933Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="RequesrAndResponse">
<meta name="twitter:description" content="###　Response ###1234567891011121314151617181920212223242526Response对象,用于生成http响应信息. 对于开发人员来讲,就是 向response 对象中添加信息即可.	响应首行		HTTP/1.1  200 OK		void setStatus(int sc) 		void setStatus(int sc, String sm)">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    sidebar: {"position":"left","display":"always"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2017/01/15/RequesrAndResponse/"/>





  <title> RequesrAndResponse | JokerLiang </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  








  <div style="display: none;">
    <script src="//s95.cnzz.com/z_stat.php?id=1260895995&web_id=1260895995" language="JavaScript"></script>
  </div>





  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">JokerLiang</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">永远年轻，永远热泪盈眶。</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup">
 <span class="search-icon fa fa-search"></span>
 <input type="text" id="local-search-input">
 <div id="local-search-result"></div>
 <span class="popup-btn-close">close</span>
</div>


    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
  <link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/01/15/RequesrAndResponse/">

  <span style="display:none" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <meta itemprop="name" content="JokerLiang">
    <meta itemprop="description" content="">
    <meta itemprop="image" content="/images/me.jpg">
  </span>

  <span style="display:none" itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
    <meta itemprop="name" content="JokerLiang">
    <span style="display:none" itemprop="logo" itemscope itemtype="http://schema.org/ImageObject">
      <img style="display:none;" itemprop="url image" alt="JokerLiang" src="">
    </span>
  </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                RequesrAndResponse
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2017-01-15T10:23:06+08:00">
                2017-01-15
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/JAVAWEB/" itemprop="url" rel="index">
                    <span itemprop="name">JAVAWEB</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          

          
          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>###&#x3000;Response ###<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">Response&#x5BF9;&#x8C61;,&#x7528;&#x4E8E;&#x751F;&#x6210;http&#x54CD;&#x5E94;&#x4FE1;&#x606F;. &#x5BF9;&#x4E8E;&#x5F00;&#x53D1;&#x4EBA;&#x5458;&#x6765;&#x8BB2;,&#x5C31;&#x662F; &#x5411;response &#x5BF9;&#x8C61;&#x4E2D;&#x6DFB;&#x52A0;&#x4FE1;&#x606F;&#x5373;&#x53EF;.</span><br><span class="line"></span><br><span class="line">	&#x54CD;&#x5E94;&#x9996;&#x884C;</span><br><span class="line">		HTTP/1.1  200 OK</span><br><span class="line">		void setStatus(int sc) </span><br><span class="line">		void setStatus(int sc, String sm) Deprecated(&#x8FC7;&#x65F6;)</span><br><span class="line">		void sendError(int sc) </span><br><span class="line">        void sendError(int sc, String msg) </span><br><span class="line">		</span><br><span class="line"> 		</span><br><span class="line">	&#x54CD;&#x5E94;&#x5934;</span><br><span class="line">		&#x952E;:&#x503C;</span><br><span class="line">		void setHeader(String name, String value)  &#x8BBE;&#x7F6E;&#x952E;&#x503C;&#x5BF9;.</span><br><span class="line">				void setDateHeader(String name, long date) &#x8BBE;&#x7F6E;&#x952E;&#x503C;&#x5BF9;.</span><br><span class="line">				void setIntHeader(String name, int value)  &#x8BBE;&#x7F6E;&#x952E;&#x503C;&#x5BF9;.</span><br><span class="line">		void addHeader(String name, String value) &#x6DFB;&#x52A0;&#x952E;&#x503C;&#x5BF9;.</span><br><span class="line">			void addDateHeader(String name, long date)&#x6DFB;&#x52A0;&#x952E;&#x503C;&#x5BF9;.</span><br><span class="line">			void addIntHeader(String name, int value) &#x6DFB;&#x52A0;&#x952E;&#x503C;&#x5BF9;.</span><br><span class="line"> </span><br><span class="line"></span><br><span class="line">	&#x54CD;&#x5E94;&#x7A7A;&#x884C;</span><br><span class="line">	&#x54CD;&#x5E94;&#x6B63;&#x6587;</span><br><span class="line">		&#x9700;&#x8981;&#x7ED9;&#x6D4F;&#x89C8;&#x5668;&#x7684;&#x8D44;&#x6E90;</span><br><span class="line">			getWriter(); &#x5B57;&#x7B26;&#x6D41;.</span><br><span class="line">			getOutputStream() &#x5B57;&#x8282;&#x6D41;</span><br></pre></td></tr></table></figure></p>
<h3 id="Request"><a href="#Request" class="headerlink" title="Request"></a>Request</h3><a id="more"></a>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line">HTTP&#x8BF7;&#x6C42;&#x534F;&#x8BAE;:</span><br><span class="line">	&#x8BF7;&#x6C42;&#x9996;&#x884C;			&#x8BF7;&#x6C42;&#x65B9;&#x5F0F;  &#x8BF7;&#x6C42;&#x8DEF;&#x5F84;	&#x534F;&#x8BAE;/&#x7248;&#x672C;&#x53F7;</span><br><span class="line">		String getMethod()  &#x83B7;&#x5F97;&#x8BF7;&#x6C42;&#x65B9;&#x5F0F;</span><br><span class="line">		request.getContextPath(): /day08-request &#x83B7;&#x5F97;&#x9879;&#x76EE;&#x8DEF;&#x5F84;</span><br><span class="line">		String getServletPath() </span><br><span class="line">		request.getQueryString(): name=tom?age=19  &#x83B7;&#x5F97;&#x8BF7;&#x6C42;&#x8DEF;&#x5F84;&#x4E2D;&#x7684;&#x53C2;&#x6570;</span><br><span class="line">		request.getRequestURI(): /day08-request/AServlet  &#x83B7;&#x5F97;&#x5F53;&#x524D;&#x8BBF;&#x95EE;&#x7684;&#x76F8;&#x5BF9;&#x8DEF;&#x5F84;,&#x76F8;&#x5BF9;&#x4E3B;&#x673A;&#x8DEF;&#x5F84;</span><br><span class="line">		request.getRequestURL(): http://localhost:8080/day08-request/AServlet &#x83B7;&#x5F97;&#x5F53;&#x524D;&#x8BBF;&#x95EE;&#x7684;&#x7EDD;&#x5BF9;&#x8DEF;&#x5F84;</span><br><span class="line">		request.getServletPath(): /AServlet &#x83B7;&#x5F97;servlet&#x8DEF;&#x5F84;</span><br><span class="line">		String getScheme()  &#x83B7;&#x5F97;&#x534F;&#x8BAE;&#x534F;&#x8BAE;</span><br><span class="line">	&#x8BF7;&#x6C42;&#x5934;				&#x952E;:&#x503C;</span><br><span class="line">		 request.getContentLength(): -1 &#x8FD4;&#x56DE;&#x6B63;&#x6587;&#x5185;&#x5BB9;&#x957F;&#x5EA6;</span><br><span class="line">		 request.getContentType(): null &#x8FD4;&#x56DE;&#x6B63;&#x6587;&#x5185;&#x5BB9;&#x7C7B;&#x578B;</span><br><span class="line">		 request.getLocale(): zh_HANS_CN  &#x83B7;&#x5F97;accept-language:zh_CN</span><br><span class="line">		 request.getServerName(): localhost &#x83B7;&#x5F97;&#x4E3B;&#x673A;&#x540D;&#x79F0;</span><br><span class="line">		 request.getServerPort(): 8080 &#x83B7;&#x5F97;&#x8BBF;&#x95EE;&#x7AEF;&#x53E3;&#x53F7;</span><br><span class="line">		 </span><br><span class="line">		 </span><br><span class="line">		 String getHeader(String name) &#x6839;&#x636E;&#x952E;&#x83B7;&#x5F97;&#x503C;(&#x503C;&#x53EA;&#x6709;&#x4E00;&#x4E2A;)</span><br><span class="line">				 long getDateHeader(String name)</span><br><span class="line">				 int getIntHeader(String name) </span><br><span class="line">		 Enumeration getHeaderNames()  &#x83B7;&#x5F97;&#x6240;&#x6709;&#x8BF7;&#x6C42;&#x5934;&#x7684;&#x540D;&#x5B57;</span><br><span class="line">		 Enumeration getHeaders(String name)  &#x6839;&#x636E;&#x952E;&#x83B7;&#x5F97;&#x503C;(&#x503C;&#x6709;&#x591A;&#x4E2A;)</span><br><span class="line">				  </span><br><span class="line">		 </span><br><span class="line"></span><br><span class="line">	&#x8BF7;&#x6C42;&#x7A7A;&#x884C;			</span><br><span class="line">	&#x8BF7;&#x6C42;&#x6B63;&#x6587;			post&#x8BF7;&#x6C42;&#x624D;&#x6709;=&gt; &#x8BF7;&#x6C42;&#x53C2;&#x6570; =&gt; name=tom&amp;age=18</span><br><span class="line">			 String getParameter(String name) &#x6839;&#x636E;&#x53C2;&#x6570;&#x952E;&#x83B7;&#x5F97;&#x53C2;&#x6570;&#x503C;</span><br><span class="line">			 Map&lt;String,String[]&gt; getParameterMap() &#x8FD4;&#x56DE;&#x5C01;&#x88C5;&#x53C2;&#x6570;&#x7684;Map</span><br><span class="line">			 Enumeration getParameterNames() &#x83B7;&#x5F97;&#x6240;&#x6709;&#x53C2;&#x6570;&#x7684;&#x952E;</span><br><span class="line">			 String[] getParameterValues(String name)  &#x6839;&#x636E;&#x53C2;&#x6570;&#x952E;&#x83B7;&#x5F97;&#x53C2;&#x6570;&#x503C;(&#x503C;&#x6709;&#x591A;&#x4E2A;)</span><br><span class="line"></span><br><span class="line">	&#x7F51;&#x7EDC;&#x7F16;&#x7A0B;</span><br><span class="line">	request.getRemoteAddr(): 192.168.13.102</span><br><span class="line">	request.getRemoteHost(): 192.168.13.102</span><br><span class="line">	request.getRemotePort(): 53479</span><br></pre></td></tr></table></figure>
<h3 id="response&#xFF1A;&#x54CD;&#x5E94;&#x5BF9;&#x8C61;"><a href="#response&#xFF1A;&#x54CD;&#x5E94;&#x5BF9;&#x8C61;" class="headerlink" title="response&#xFF1A;&#x54CD;&#x5E94;&#x5BF9;&#x8C61;"></a>response&#xFF1A;&#x54CD;&#x5E94;&#x5BF9;&#x8C61;</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br></pre></td><td class="code"><pre><span class="line">* &#x529F;&#x80FD;&#xFF1A;&#x8BBE;&#x7F6E;&#x54CD;&#x5E94;&#x6D88;&#x606F;</span><br><span class="line"></span><br><span class="line">* &#x8BBE;&#x7F6E;&#x54CD;&#x5E94;&#x884C;&#xFF1A;  HTTP/1.1  200 ok</span><br><span class="line">	</span><br><span class="line">	* &#x8BBE;&#x7F6E;&#x54CD;&#x5E94;&#x72B6;&#x6001;&#x7801;&#xFF1A;setStatus(int st);</span><br><span class="line">		* &#x91CD;&#x5B9A;&#x5411;&#x529F;&#x80FD;&#x5B9E;&#x73B0;&#xFF1A;</span><br><span class="line">			//&#x8BBE;&#x7F6E;&#x54CD;&#x5E94;&#x72B6;&#x6001;&#x7801;  302</span><br><span class="line">			response.setStatus(302);</span><br><span class="line">			//&#x8BBE;&#x7F6E;&#x5934;  location</span><br><span class="line">			response.setHeader(&quot;location&quot;, &quot;http://www.baidu.com&quot;);</span><br><span class="line">			</span><br><span class="line">			</span><br><span class="line">			//&#x7B80;&#x5316;&#x7248;&#x91CD;&#x5B9A;&#x5411;</span><br><span class="line">			response.sendRedirect(&quot;http://www.sina.com&quot;);</span><br><span class="line">			</span><br><span class="line">			* &#x91CD;&#x5B9A;&#x5411;&#x7279;&#x70B9;&#xFF1A;</span><br><span class="line">				* 2&#x6B21;&#x8BF7;&#x6C42; 2&#x6B21;&#x54CD;&#x5E94;&#x3002;2&#x4E2A;request&#x5BF9;&#x8C61;</span><br><span class="line">				* &#x5730;&#x5740;&#x680F;&#x53D1;&#x751F;&#x53D8;&#x5316;</span><br><span class="line">				* &#x53EF;&#x4EE5;&#x91CD;&#x5B9A;&#x5411;&#x5230;&#x5916;&#x90E8;&#x7AD9;&#x70B9;</span><br><span class="line">	</span><br><span class="line">* &#x8BBE;&#x7F6E;&#x54CD;&#x5E94;&#x5934;&#xFF1A;Content-Type: text/html;charset=utf-8;</span><br><span class="line">	* &#x8BBE;&#x7F6E;&#x54CD;&#x5E94;&#x5934;&#xFF1A;</span><br><span class="line">		setHeader(String name,String value);</span><br><span class="line">		setDateHeader(String name,Date date);</span><br><span class="line">		setIntHeader(String name ,int value);</span><br><span class="line">		</span><br><span class="line">		//&#x8BBE;&#x7F6E;content-type&#x5934;.&#x89E3;&#x51B3;&#x4E71;&#x7801;&#x95EE;&#x9898;</span><br><span class="line">		//response.setHeader(&quot;content-type&quot;, &quot;text/html;charset=utf-8&quot;);</span><br><span class="line">		//&#x7B80;&#x5316;&#x5F62;&#x5F0F;</span><br><span class="line">		response.setContentType(&quot;text/html;charset=utf-8&quot;);</span><br><span class="line">		response.getWriter().write(&quot;&lt;h1&gt;&#x9ED1;&#x9A6C;&#x8BAD;&#x7EC3;&#x8425;&lt;/h1&gt;&quot;);</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">* &#x8BBE;&#x7F6E;&#x54CD;&#x5E94;&#x4F53;&#xFF1A;</span><br><span class="line">	* &#x53D1;&#x9001;&#x5B57;&#x7B26;&#x6570;&#x636E;</span><br><span class="line">		PrintWriter  getWriter():</span><br><span class="line">			* &#x8BBE;&#x7F6E;&#x8F93;&#x51FA;&#x6D41;&#x7684;&#x7F16;&#x7801;&#xFF1A;setCharacterEncoding(&quot;utf-8&quot;);</span><br><span class="line">			* &#x8BBE;&#x7F6E;content-type&#x7C7B;&#x578B;,&#x544A;&#x8BC9;&#x6D4F;&#x89C8;&#x5668;&#x670D;&#x52A1;&#x5668;&#x4F7F;&#x7528;&#x7684;&#x7F16;&#x7801;&#x65B9;&#x5F0F;&#xFF0C;&#x5E76;&#x4E14;&#x5EFA;&#x8BAE;&#x6D4F;&#x89C8;&#x5668;&#x4F7F;&#x7528;&#x8FD9;&#x79CD;&#x65B9;&#x5F0F;&#x89E3;&#x7801;</span><br><span class="line">				setContentType(&quot;text/html;charset=utf-8&quot;);</span><br><span class="line">				* &#x8BE5;&#x65B9;&#x6CD5;&#x4E0D;&#x7D27;&#x53EF;&#x4EE5;&#x8BBE;&#x7F6E;&#x54CD;&#x5E94;&#x5934;&#xFF0C;&#x8FD8;&#x53EF;&#x4EE5;&#x8BBE;&#x7F6E;&#x6D41;&#x7684;&#x7F16;&#x7801;</span><br><span class="line">			</span><br><span class="line">			* &#x6CE8;&#x610F;&#xFF1A;&#x8BBE;&#x7F6E;&#x7F16;&#x7801;&#x7684;&#x64CD;&#x4F5C;&#xFF0C;&#x5FC5;&#x987B;&#x4F4D;&#x4E8E;&#x83B7;&#x53D6;&#x6D41;&#x5BF9;&#x8C61;&#x4E4B;&#x524D;&#x3002;</span><br><span class="line">		</span><br><span class="line">		</span><br><span class="line">	* &#x53D1;&#x9001;&#x5B57;&#x8282;&#x6570;&#x636E;&#xFF1A;</span><br><span class="line">		ServletOutputStream  getOutputStream():</span><br></pre></td></tr></table></figure>
<h3 id="request&#xFF1A;&#x8BF7;&#x6C42;&#x5BF9;&#x8C61;"><a href="#request&#xFF1A;&#x8BF7;&#x6C42;&#x5BF9;&#x8C61;" class="headerlink" title="request&#xFF1A;&#x8BF7;&#x6C42;&#x5BF9;&#x8C61;"></a>request&#xFF1A;&#x8BF7;&#x6C42;&#x5BF9;&#x8C61;</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br></pre></td><td class="code"><pre><span class="line">* &#x5C01;&#x88C5;&#x4E86;&#x8BF7;&#x6C42;&#x6D88;&#x606F;&#x6570;&#x636E;</span><br><span class="line"></span><br><span class="line">* &#x529F;&#x80FD;&#xFF1A;</span><br><span class="line">	* &#x83B7;&#x53D6;&#x8BF7;&#x6C42;&#x6D88;&#x606F;&#xFF1A;</span><br><span class="line">		&#x6D88;&#x606F;&#x884C;&#xFF1A;</span><br><span class="line">			getMethod():&#x83B7;&#x53D6;&#x8BF7;&#x6C42;&#x65B9;&#x5F0F;  &#x5982;&#xFF1A;GET&#x3001;POST...</span><br><span class="line">			getContextPath():&#x83B7;&#x53D6;&#x865A;&#x62DF;&#x76EE;&#x5F55;&#x3002; &#x5982;&#xFF1A;/day08</span><br><span class="line">				&#x865A;&#x62DF;&#x76EE;&#x5F55;:&#x9879;&#x76EE;&#x8BBF;&#x95EE;&#x7684;URI(&#x8DEF;&#x5F84;)</span><br><span class="line">			</span><br><span class="line">			getRequestURI():&#x83B7;&#x53D6;URI&#xFF1A;&#x7EDF;&#x4E00;&#x8D44;&#x6E90;&#x6807;&#x8BC6;&#x7B26;</span><br><span class="line">			getRequestURL():&#x83B7;&#x53D6;URL&#xFF1A;&#x7EDF;&#x4E00;&#x8D44;&#x6E90;&#x5B9A;&#x4F4D;&#x7B26;</span><br><span class="line">				URL:http://localhost:8080/day08/index.jsp</span><br><span class="line">				URI:/day08/index.jsp</span><br><span class="line">			</span><br><span class="line">			getQueryString():&#x83B7;&#x53D6;get&#x8BF7;&#x6C42;&#x7684;&#x8BF7;&#x6C42;&#x53C2;&#x6570;</span><br><span class="line">			getRemoteAddr():&#x83B7;&#x53D6;&#x5BA2;&#x6237;&#x7AEF;&#x7684;IP&#x5730;&#x5740;</span><br><span class="line">			</span><br><span class="line">			</span><br><span class="line">		&#x6D88;&#x606F;&#x5934;&#xFF1A;</span><br><span class="line">			getHeader(String name):&#x6839;&#x636E;&#x540D;&#x79F0;&#x83B7;&#x53D6;&#x503C;</span><br><span class="line">			Enumeration getHeaderNames() :&#x83B7;&#x53D6;&#x6240;&#x6709;&#x8BF7;&#x6C42;&#x5934;&#x7684;&#x540D;&#x79F0;</span><br><span class="line">		</span><br><span class="line">		&#x6D88;&#x606F;&#x4F53;&#xFF1A;&#x5C01;&#x88C5;&#x4E86;post&#x8BF7;&#x6C42;&#x7684;&#x53C2;&#x6570;</span><br><span class="line">			* getReader():&#x83B7;&#x53D6;&#x5B57;&#x7B26;&#x6570;&#x636E;</span><br><span class="line">			* getInputStream():&#x83B7;&#x53D6;&#x5B57;&#x8282;&#x6570;&#x636E;</span><br><span class="line">			</span><br><span class="line">			</span><br><span class="line">		* &#x7EDF;&#x4E00;&#x7684;&#x65B9;&#x5F0F;&#x83B7;&#x53D6;&#x8BF7;&#x6C42;&#x53C2;&#x6570;&#xFF1A;</span><br><span class="line">			* String getParameter(String name): &#x6839;&#x636E;&#x8BF7;&#x6C42;&#x53C2;&#x6570;&#x7684;&#x540D;&#x79F0; &#x83B7;&#x53D6;&#x503C;</span><br><span class="line">			* String[] getParameterValues(String name):&#x6839;&#x636E;&#x8BF7;&#x6C42;&#x53C2;&#x6570;&#x540D;&#x79F0; &#x83B7;&#x53D6;&#x503C; (&#x6570;&#x7EC4;)&#xFF0C;&#x7528;&#x4E8E;checkbox</span><br><span class="line">			* Map&lt;String,String[]&gt;   getParameterMap():&#x83B7;&#x53D6;&#x8BF7;&#x6C42;&#x53C2;&#x6570;&#x7684;&#x952E;&#x503C;&#x5BF9;&#x96C6;&#x5408;</span><br><span class="line">			* getParameterNames():&#x83B7;&#x53D6;&#x6240;&#x6709;&#x53C2;&#x6570;&#x7684;&#x540D;&#x79F0;</span><br><span class="line">			</span><br><span class="line">			</span><br><span class="line">	* &#x5979;&#x662F;&#x4E00;&#x4E2A;&#x57DF;&#x5BF9;&#x8C61;</span><br><span class="line">		* &#x4EE3;&#x8868;&#x8BF7;&#x6C42;&#x57DF;</span><br><span class="line">		setAttribute():</span><br><span class="line">		getAttribute():</span><br><span class="line">		removeAttribute():</span><br><span class="line">	</span><br><span class="line">	* &#x8BF7;&#x6C42;&#x8F6C;&#x53D1;:</span><br><span class="line">		request.getRequestDispatcher(&quot;/req6&quot;).forward(request, response);</span><br><span class="line">		</span><br><span class="line">		* &#x7279;&#x70B9;&#xFF1A;</span><br><span class="line">			* &#x4E00;&#x6B21;&#x8BF7;&#x6C42;&#xFF0C;&#x4E00;&#x6B21;&#x54CD;&#x5E94;&#xFF0C;&#x53EA;&#x6709;&#x4E00;&#x4E2A;request&#x5BF9;&#x8C61;&#xFF0C;&#x53EF;&#x4EE5;&#x5728;request&#x57DF;&#x4E2D;&#x5171;&#x4EAB;&#x6570;&#x636E;</span><br><span class="line">			* &#x5730;&#x5740;&#x680F;&#x4E0D;&#x53D1;&#x751F;&#x53D8;&#x5316;</span><br><span class="line">			* &#x53EA;&#x80FD;&#x8F6C;&#x53D1;&#x5230;&#x5F53;&#x524D;&#x9879;&#x76EE;&#x4E2D;</span><br><span class="line">			</span><br><span class="line">			* &#x7ED3;&#x8BBA;&#xFF1A;&#x5982;&#x679C;&#x5728;&#x8BBF;&#x95EE;&#x591A;&#x4E2A;&#x8D44;&#x6E90;&#x4E2D;&#xFF0C;&#x5982;&#x679C;&#x8981;&#x5171;&#x4EAB;&#x6570;&#x636E;&#xFF0C;&#x5C31;&#x4F7F;&#x7528;&#x8BF7;&#x6C42;&#x8F6C;&#x53D1;&#xFF0C;&#x53CD;&#x4E4B;&#xFF0C;&#x4F7F;&#x7528;&#x91CD;&#x5B9A;&#x5411;</span><br></pre></td></tr></table></figure>
      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>


    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/JAVAWEB/" rel="tag"># JAVAWEB</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/01/15/数据库常用语句/" rel="next" title="数据库常用语句">
                <i class="fa fa-chevron-left"></i> 数据库常用语句
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/01/15/Servlet/" rel="prev" title="Servet">
                Servet <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/me.jpg"
               alt="JokerLiang" />
          <p class="site-author-name" itemprop="name">JokerLiang</p>
          <p class="site-description motion-element" itemprop="description">永远年轻，永远热泪盈眶。</p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">61</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">15</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">17</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/LoverJoker" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://www.zhihu.com/people/lover-easy-7/activities" target="_blank" title="Twitter">
                  
                    <i class="fa fa-fw fa-twitter"></i>
                  
                  Twitter
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://weibo.com/2292572142/profile?rightmod=1&wvr=6&mod=personinfo" target="_blank" title="微博">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  微博
                </a>
              </span>
            
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              Friends
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.knight.ac.cn/" title="Knight" target="_blank">Knight</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://lzllzl.cn/" title="Zayvion" target="_blank">Zayvion</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://chen97.com/" title="Chens" target="_blank">Chens</a>
                </li>
              
            </ul>
          </div>
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#Request"><span class="nav-number">1.</span> <span class="nav-text">Request</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#response：响应对象"><span class="nav-number">2.</span> <span class="nav-text">response：响应对象</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#request：请求对象"><span class="nav-number">3.</span> <span class="nav-text">request：请求对象</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">JokerLiang</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Mist
  </a>
</div>


        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>



  



  




	




  
  
  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length == 0) {
      search_path = "search.xml";
    }
    var path = "/" + search_path;
    // monitor main search box;

    function proceedsearch() {
      $("body").append('<div class="popoverlay">').css('overflow', 'hidden');
      $('.popup').toggle();
    }
    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';
      $.ajax({
        url: path,
        dataType: "xml",
        async: true,
        success: function( xmlResponse ) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = $( "entry", xmlResponse ).map(function() {
            return {
              title: $( "title", this ).text(),
              content: $("content",this).text(),
              url: $( "url" , this).text()
            };
          }).get();
          var $input = document.getElementById(search_id);
          var $resultContent = document.getElementById(content_id);
          $input.addEventListener('input', function(){
            var matchcounts = 0;
            var str='<ul class=\"search-result-list\">';
            var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
            $resultContent.innerHTML = "";
            if (this.value.trim().length > 1) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var content_index = [];
                var data_title = data.title.trim().toLowerCase();
                var data_content = data.content.trim().replace(/<[^>]+>/g,"").toLowerCase();
                var data_url = decodeURIComponent(data.url);
                var index_title = -1;
                var index_content = -1;
                var first_occur = -1;
                // only match artiles with not empty titles and contents
                if(data_title != '') {
                  keywords.forEach(function(keyword, i) {
                    index_title = data_title.indexOf(keyword);
                    index_content = data_content.indexOf(keyword);
                    if( index_title >= 0 || index_content >= 0 ){
                      isMatch = true;
                      if (i == 0) {
                        first_occur = index_content;
                      }
                    }

                  });
                }
                // show search results
                if (isMatch) {
                  matchcounts += 1;
                  str += "<li><a href='"+ data_url +"' class='search-result-title'>"+ data_title +"</a>";
                  var content = data.content.trim().replace(/<[^>]+>/g,"");
                  if (first_occur >= 0) {
                    // cut out 100 characters
                    var start = first_occur - 20;
                    var end = first_occur + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if(start == 0){
                      end = 50;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    var match_content = content.substring(start, end);
                    // highlight all keywords
                    keywords.forEach(function(keyword){
                      var regS = new RegExp(keyword, "gi");
                      match_content = match_content.replace(regS, "<b class=\"search-keyword\">"+keyword+"</b>");
                    });

                    str += "<p class=\"search-result\">" + match_content +"...</p>"
                  }
                  str += "</li>";
                }
              })};
            str += "</ul>";
            if (matchcounts == 0) { str = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>' }
            if (keywords == "") { str = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>' }
            $resultContent.innerHTML = str;
          });
          proceedsearch();
        }
      });}

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched == false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(function(e){
      $('.popup').hide();
      $(".popoverlay").remove();
      $('body').css('overflow', '');
    });
    $('.popup').click(function(e){
      e.stopPropagation();
    });
  </script>


  

  

  

  


</body>
</html>
